<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
.menu{
	font-size:12px;
	height:20;
	padding-top:4px;
	padding-left:28px;
	}
.checkmenu{
	font-size:12px;
	height:20;
	padding-top:4px;
	}
body{
	cursor:default;
	margin:0;
	border:1px solid #000000;
	}
#iMenu{
	background-image:url(images/bg_contextmenu.gif);
	}
</style>
<script>
	var _jEditor			= null;
	var _hide				= false;
	var menuQueue			= [];

	document.onselectstart	= function()
							  {
								return false;
							  }

	window.onfocus			= function()
							  {
								try
								{
									window.focus();
								}
								catch(e)
								{
								}
							  }
	window.onblur			= function()
							  {
								if(_hide)
								{
									kill();
								}
							  }




	function kill()
	{
		_jEditor.contextMenu.style.visibility		= 'hidden';
	}

	function resize()
	{
		_jEditor.contextMenu.style.height			= document.body.scrollHeight;
	}

	function public_initMenu(e,id)
	{
		_hide						= false;
		setTimeout('_hide=true',100);

		_jEditor					= e;

		menuQueue					= [];
		if(iMenu.hasChildNodes())
		{
			iMenu.innerHTML			= '';
		}
		resize();

		for(var i=1;i<_jEditor.contextMenu.childNodes.length;i++)
		{
			if(_jEditor.contextMenu.childNodes[i].nodeType==1)
			{
				var paramNode			= _jEditor.contextMenu.childNodes[i];

				if(paramNode.handle==id && eval('with(_jEditor){'+paramNode.enable+'}'))
				{
					menuQueue[i-1]		= new menuItem(paramNode.id,paramNode.value,paramNode.cmd,paramNode.type,paramNode.checked);
				}
			}
		}
		if(iMenu.innerHTML=='')
		{
			kill();
		}
		else
		{
			resize();
		}
	}

	function menuItem(id,value,cmd,type,checked)
	{
		var menuObj			= null;

		switch(type)
		{
			case 'menu':
				this.id				= id;
				this.value			= value;
				this.cmd			= cmd;
				this.type			= type;

				menuObj				= document.createElement('DIV');
				menuObj.id			= this.id;
				menuObj.innerText		= this.value;
				menuObj.className		= 'menu';
				menuObj.onmousedown		= function()
										  {
											this.setCapture();
										  }
				menuObj.onmouseup		= function()
										  {
											with(_jEditor)
											{
												eval(cmd);
											}
											this.releaseCapture();
											kill();
										  }
				menuObj.onmouseover		= function()
										  {
											this.style.backgroundColor	= '#999999';
											this.style.color			= '#FFFFFF';
										  }
				menuObj.onmouseout		= function()
										  {
											this.style.backgroundColor	= '';
											this.style.color			= '';
										  }
				break;
			case 'checkmenu':
				this.id				= id;
				this.value			= value;
				this.cmd			= cmd;
				this.type			= type;

				menuObj					= document.createElement('DIV');
				menuObj.id				= this.id;
				menuObj.checked			= new Function('with(_jEditor){'+checked+'}')();
				if(menuObj.checked)
				{
					menuObj.innerHTML	= '<img src=images/checked.gif width=18 height=18 align=absmiddle hspace=5>'+this.value;
				}
				else
				{
					menuObj.innerHTML	= '<img src=images/checked.gif style="filter:chroma(color=#000000)" width=18 height=18 align=absmiddle hspace=5>'+this.value;
				}

				menuObj.className		= 'checkmenu';
				menuObj.onmousedown		= function()
										  {
											this.setCapture();
										  }
				menuObj.onmouseup		= function()
										  {
											with(_jEditor)
											{
												eval(cmd);
											}
											this.releaseCapture();
											kill();
										  }
				menuObj.onmouseover		= function()
										  {
											this.style.backgroundColor		= '#999999';
											this.style.color				= '#FFFFFF';
											if(this.checked)
											{
												this.firstChild.style.filter	= 'invert()';
											}
										  }
				menuObj.onmouseout		= function()
										  {
											this.style.backgroundColor		= '';
											this.style.color				= '';
											if(this.checked)
											{
												this.firstChild.style.filter	= '';
											}
										  }
				break;
			case 'separator':
				menuObj				= document.createElement('<div align=right style="width:68;margin-left:27;margin-top:1;margin-bottom:2;height:2;border-bottom:1px solid #CCCCCC;line-height:1;font-size:1;overflow:hidden">')
				break;
		}
		iMenu.appendChild(menuObj);

		return menuObj;
		
	}
</script>
</HEAD>

<BODY>
<div id=iMenu></div>
</BODY>
</HTML>
